package nl.saxion.cryptobazen.ui;

import java.awt.EventQueue;
import java.io.FileNotFoundException;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import nl.saxion.cryptobazen.model.Partijen;
import nl.saxion.cryptobazen.xmlreader.XmlReader;

public class Main
{

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				try
				{
					Main window = new Main();
					window.frame.setVisible(true);
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Main()
	{
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize()
	{
		frame = new JFrame();
		frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		Partijen partijen;
		try
		{
			partijen = XmlReader.readPartijen();
			frame.add(new PartijOverzichtPanel(partijen));

		}
		catch (FileNotFoundException e)
		{
			JOptionPane.showMessageDialog(frame, "Applicatie kon niet worden gestart, reden: " + e.getMessage());
		}
	}

}
